package si.yun.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import si.yun.service.OpeService;
import si.yun.utils.JsonData;

import java.util.List;
import java.util.Map;

/**
 * @ClassName OpeHomeWeb
 * @description:
 * @Author 李军瑶
 * @Date 2021/7/29 16:08
 **/
@RestController
@RequestMapping("/OpeHome")
public class OpeHomeWeb {

    @Autowired
    private OpeService service;

    /*
    * @Description 统计昨日订单数和昨日销售额度
    * @return si.yun.utils.JsonData
    * @Date 19:35 2021/7/29
    */
    @GetMapping("/getYesterdayOrder")
    public JsonData getYesterdayOrder(){
        List<Map<String,Object>> count=service.getYesterdayOrder();
        return count!=null?JsonData.buildSuccess(count):JsonData.buildError("信息为空");
    }

    /*
     * @Description 统计全部订单数和销售总额
     * @return si.yun.utils.JsonData
     * @Date 16:22 2021/7/29
     */
    @GetMapping("/getAllOrders")
    public JsonData getAllOrders(){
        List<Map<String,Object>> count=service.getAllOrders();
        return count!=null?JsonData.buildSuccess(count):JsonData.buildError("信息为空");
    }

    /*
    * @Description 统计待审核课程
    * @return si.yun.utils.JsonData
    * @Date 8:48 2021/7/30
    */
    @GetMapping("/getAuditCourses")
    public JsonData getAuditCourses(Integer AuditCourses){
        List<Map<String,Object>> count=service.getAuditCourses(AuditCourses);
        return count!=null?JsonData.buildSuccess(count):JsonData.buildError("信息为空");
    }

    /*
    * @Description 统计待审核商品
    * @return si.yun.utils.JsonData
    * @Date 9:57 2021/7/30
    */
    @PostMapping("/getAuditProduct")
    public JsonData getAuditProduct(Integer AuditProduct){
        List<Map<String,Object>> count=service.getAuditProduct(AuditProduct);
        return count!=null?JsonData.buildSuccess(count):JsonData.buildError("信息为空");
    }

    /*
    * @Description 获取指定日期内所有订单——统计图
    * @return si.yun.utils.JsonData
    * @Date 21:25 2021/8/1
    */
    @PostMapping("/getSpecifyDate")
    public JsonData getSpecifyDate(String SpecifyDate){
        List<Integer> count=service.getSpecifyDate(SpecifyDate);
        return count!=null?JsonData.buildSuccess(count):JsonData.buildError("信息为空");
    }

    @PostMapping("/getOrdersNumber")
    public JsonData getOrdersNumber(String yesterday,String today){
        Integer count=service.getOrdersNumber(yesterday,today);
        return count!=null?JsonData.buildSuccess(count):JsonData.buildError("信息为空");
    }



}
